<!-- Create a header in the default WordPress 'wrap' container -->
<div class="wrap">
    <div id="icon-plugins" class="icon32"></div>
    <h2>WP cr mobile</h2>

    <h3>Companies</h3>
    <?php
    // Show new company button for admins
    if ($admin):
    ?>
    <p>
        <a href='<?php echo $newUrl; ?>' class='button'>New Company</a>
    </p>
    <?php endif; ?>


    <table class="wp-list-table widefat fixed posts" style="width: 610px;">
        <tr>
            <th>Company Name</th>
            <th style="width: 180px;text-align: left;" align="left">Actions</th>
        </tr>
        <?php
        foreach ($companies as $company) {
        $edit = add_query_arg(
            array_merge($queryArgs, array(
                'action' => 'edit',
                'id' => $company['ID']
            )),
            $baseUrl
        );
        $moderate = add_query_arg(
            array_merge($queryArgs, array(
                'action' => 'moderate',
                'id' => $company['ID']
            )),
            $baseUrl
        );
        $delete = add_query_arg(
            array_merge($queryArgs, array(
                'action' => 'delete',
                'id' => $company['ID']
            )),
            $baseUrl
        );
        ?>
        <tr>
            <td><?php echo stripslashes($company['name']); ?></td>
            <td align="left">
                <?php
                if ($admin) { ?>
                <a href="<?php echo $edit; ?>" class="button">Edit</a>
                <a href="<?php echo $delete; ?>" class="button delbtn">Delete</a>
                <?php } ?>
                <a href="<?php echo $moderate; ?>" class="button">Moderate</a>
            </td>
        </tr>
        <?php
        }
        ?>
    </table>


    <?php
    // Show license key field for admins
if ($admin):
    ?>
    <h3>License</h3>
    <form method="post" action="<?php echo $formUrl ?>">
        <?php
        wp_nonce_field('opt_wp_crmobile _man', 'opt_wp_crmobile _man_nonce');
        ?>
        <table class="form-table">
            <tr valign="top">
            <th scope="row"><label for="license_key">License Key</label></th>
            <td>
                <input type="password" id="license_key" name="license_key" class="regular-text" value="<?php echo $license_key; ?>" />
                    <?php
                        submit_button('Save Key', 'secondary', 'submit', false);
                    ?>

                <p class="description">
    <?php
    switch ($license_key) {
        case CRMobile_Admin::LICENSE_KEY:
            echo '<span style="color:green;">&#x2713; License key is valid.</span>';
            break;
        case '':
            echo 'Enter license key to unlock premium themes.';
            break;
        default:
            echo '<span style="color:red;">&#x2717; License key is invalid.</span>';
            break;
    }
    ?>
                </p>

            </td>
            </tr>

            <tr valign="top">
            <th scope="row"><label>Themes</label></th>
            <td>
                <a href="http://www.crmobile management.com/devupgrade/" class="button">Get more themes &raquo;</a>
                <p class="description">Interested in purchasing more themes?</p>
            </td>
            </tr>
        </table>


    </form>
    <?php
endif;
    ?>

</div><!-- /.wrap -->
